package main

import (
	"bufio"
	"fmt"
	"os"
)

// func main() {
// 	counts := make(map[string]int)
// 	input := bufio.NewScanner(os.Stdin)
// 	for input.Scan() {
// 		counts[input.Text()]++
// 	}
// 	for line, n := range counts {
// 		if n > 1 {
// 			fmt.Printf("%d次%s\n", n, line)
// 		}
// 	}
// }

func main() {
	counts := make(map[string]int)
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		counts[scanner.Text()]++
	}
	for line, n := range counts {
		if n > 1 {
			fmt.Println(line, n)
		}
	}
}
